<template>
  <div class="nickName-container">
    <van-nav-bar
      title="标题"
      left-text="取消"
      right-text="确认"
      @click-left="onClickLeft"
      @click-right="onClickRight"
    />
    <div class="area-container">
      <van-field
        v-model.trim="name"
        rows="2"
        autosize
        type="textarea"
        maxlength="50"
        placeholder="请输入留言"
        show-word-limit
      />
    </div>
    =={{name}}
  </div>
</template>
           
<script>
import  {profile_api} from  '@/api/profile.js'
export default {
  data() {
    return {
      name: ''
    }
  },
  methods:{
    onClickLeft(){
      console.log(1);
      this.$emit('nickfunc')
    },
    async onClickRight(){
      //console.log(2);

      //  发送请求
      const  {data:res}=await profile_api({
        name:this.name
      })
      /* 
      获取数据成功后，=====关闭对话框 +  将最新的数据喜爱是在结构上  +  将数据同步到表单上
      
      */
      console.log(res,66666);
      this.$emit('nickfunc',res.data.name)
      this.name=res.data.name
    }
  }
}
</script>
<style scoped lang='less'>
.nickName-container {
  .van-nav-bar {
    background-color: #fff;
  }

  .area-container {
    padding: 20px;
  }
}
</style>